﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DBEngine.Elements
{
    public abstract class OrderElement 
	{

        public abstract Object this[Enum field]
         {
             get;
             set;
         }
	}

     public class Lenses : OrderElement
	{

        public enum Fields { Type, Brand };
        public enum Types { Disposable, Permenant, Toric };
        public enum Brands { Dispo, BioMedics, BauschLomb, Hanita, Soflex, TLight };

		private Types mType;
		private Brands mBrand;

        override public Object this[Enum field]
        {
            get {return this[(Fields)field]; }
            set { this[(Fields)field] = (Enum)value; }
        }
        public Enum this[Fields field]
		{
			get
			{
				Enum retval = null;
				switch (field)
				{
					case Fields.Type:
						retval = mType; break;

					case Fields.Brand:
						retval = mBrand; break;

					default:
						break;

				}
				return retval;
			}

			set
			{
				switch (field)
				{
					case Fields.Type:
						mType = (Types)(Convert.ToInt16(value)); break;
					case Fields.Brand: mBrand =(Brands)(Convert.ToInt16(value)); break;
					default:
						break;

				}
			}
		}

         public Lenses(Types mType, Brands mBrand)
         {
             this.mType = mType;
             this.mBrand = mBrand;
         }
         public Lenses() { }
     }

     public class EyeGlasses : OrderElement
     {
         public enum Fields { Glass, Singal_Vision, AR_Coating, CR_39, Bi_Focal, UV_400, Hi_Index_156, Hi_Index_160, Hi_Index_166, Hi_Index_174, TriFocal, Tint_PGX, Poly_Carbon, Progressive, CR_39_AR, Frame };
         private Dictionary<Fields, Boolean> mProperties;
         private string mFrame;
         public Object this[Fields field]
         {
             get 
             {
                 Object retval;
                 switch (field)
                 {
                     case Fields.Frame: 
                         retval =  mFrame;
                         break;
                     default: 
                         retval = mProperties[field];
                         break;
                }
                 return retval;
             }
             set 
             {
                 switch (field)
                 {
                     case Fields.Frame:
                          mFrame = (string) value;;
                         break;
                     default:
                         mProperties[field] = (Boolean)value;
                         break;
                 }
             }
         }
         override public Object this[Enum field]
         {
             get { return this[(Fields)field]; }
             set { this[(Fields)field] = value; }
         }
         public EyeGlasses() 
         {
             mProperties = new Dictionary<Fields, bool>();
             foreach (EyeGlasses.Fields glassesField in Enum.GetValues(typeof(EyeGlasses.Fields)))
             {
                 mProperties.Add(glassesField, false);
             }
             mProperties.Remove(Fields.Frame);

         }
         internal EyeGlasses(string mFrame,Dictionary<Fields, Boolean> mProperties )
         {
             this.mFrame = mFrame;
             this.mProperties = new Dictionary<Fields,Boolean>(mProperties);
         }
     }
	
	public class Order : Element
	{
		public enum Fields { ID, ClientID,ExaminationID,OrderDate,Price,OrderElement };
		
		protected int mClientId;
		protected int mExaminationID;
		protected DateTime mOrderDate;
		protected int mPrice;
		protected OrderElement mOrderElement;

        internal Order(int mClientId, int mExaminationID, DateTime mOrderDate, int mPrice, OrderElement mOrderElement)
        {
            this.mClientId = mClientId;
            this.mExaminationID = mExaminationID;
            this.mOrderDate = mOrderDate;
            this.mPrice = mPrice;
            this.mOrderElement = mOrderElement;
        }
        public Order() { }
		public Object this[Fields field]
		{
			get
			{
				Object retval = null;
				switch (field)
				{
					case Fields.ID: retval = mID; break;
					case Fields.ClientID: retval = mClientId; break;
					case Fields.ExaminationID: retval = mExaminationID; break;
					case Fields.OrderDate: retval = mOrderDate; break;
					case Fields.Price: retval = mPrice; break;
					case Fields.OrderElement: retval = mOrderElement; break; 
				}
				return retval;
			}
			set
			{
				switch (field)
				{

					case Fields.ID: mID = Convert.ToInt16(value) ; break;
					case Fields.ClientID: mClientId = Convert.ToInt16(value); break;
					case Fields.ExaminationID: mExaminationID= Convert.ToInt16(value); break;
					case Fields.OrderDate:mOrderDate = (DateTime)value; break;
					case Fields.Price: mPrice = Convert.ToInt16(value); break;
					case Fields.OrderElement: mOrderElement = (OrderElement)value; break; 
				}
			}
		}
	}
}
